# @shuaige : 陈世玉
# @name :jinqiu.py
# @time :2024/12/13 16:49
import pymysql
conn=pymysql.connect(
            host="localhost",
            port=3306,user="root",
            password="17884873770",
            database="spider01",
            charset="utf8")
cursor=conn.cursor()
sql="select jinqiu,count(1) from data group by jinqiu order by jinqiu"
cursor.execute(sql)
result=cursor.fetchall()
result=list(result)
name=[]
count=[]
for i in range(len(result)):
    name.append(int(result[i][0]))
    count.append(int(result[i][1]))
name=name[:-2]
count=count[:-2]

from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
from pyecharts.globals import ThemeType
bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.WHITE))
bar.add_xaxis(name)
bar.add_yaxis('场次',count)

bar.set_global_opts(title_opts={'text':'单场进球数','subtext':'场次分析'})
make_snapshot(snapshot,bar.render(),'bar.png')
# bar.render('jinqiu.html')